import { PageContainer } from '@ant-design/pro-components';
import { Outlet, useModel } from '@umijs/max';
import { useEffect, useState } from 'react';
import { history } from '@umijs/max';

const LayoutPage: React.FC = () => {
  const { init } = useModel('dic');
  const [ready, setReady] = useState(false);
  useEffect(() => {
    init().then(() => setReady(true));
  }, []);
 const isAuthenticated = ()=>{
  return sessionStorage.getItem('token')!==null
 };
 if(!isAuthenticated()){
  history.push('/login')
  return null
 }
  return (
    <PageContainer ghost>
      {/* <Outlet></Outlet> */}
      {ready ? <Outlet></Outlet>:<div>加载中...</div>}
    </PageContainer>
  );
};

export default LayoutPage;
